Env.aggregate(window.Array.prototype, {
	
	/**
	 * Clones the array.
	 */
	clone: function() {
		return this.slice();
	},
	
	/**
	 * Returns true if array contains the given item.
	 */
	contains: function(item) {
		return this.indexOf(item, 0) !== -1;
	},
	
	/**
	 * Returns true if array does not contain any items.
	 */
	empty: function() {
		return this.length === 0;
	},
	
	/**
	 * Erases item from the array. Should erase all duplicated items same as given too.
	 */
	erase: function(item) {
		var i = 0;

		do { if(this[i] === item) { this.splice(i, 1); i = -1; } }
		while(++i < this.length);
		
		return this;
	},

	/**
	 * Returns last element from the array (does not remove it as pop does !).
	 */
	last: function() {
		return this[this.length-1];
	}
});

/**
 * Extending Array.each to handle execution context as a second argument.
 * Same as standard Array.yuiEach - the execution is slow.
 */
Array.yuiEach = Array.each;

Array.each = function(o, c, f) {
	if(typeof c === "function") { Array.yuiEach(o, c, f); }
	else { Array.yuiEach(o, f, c); }
};